Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

dot

Package Overview
Dependencies
Maintainers
2
Versions
25
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dot

Concise and fast javascript templating compatible with nodejs and other javascript environments

  • 1.1.3
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
490K
increased by3.66%
Maintainers
2
Weekly downloads
 
Created

What is dot?

The 'dot' npm package is a fast and lightweight template engine in JavaScript. It allows you to create dynamic HTML templates with embedded JavaScript logic. It is known for its simplicity and performance, making it suitable for both client-side and server-side rendering.

What are dot's main functionalities?

Basic Template Rendering

This feature allows you to create a basic template and render it with dynamic data. The template string contains placeholders that are replaced with actual data when the template is rendered.

const doT = require('dot');
const template = doT.template('Hello, {{=it.name}}!');
const result = template({ name: 'World' });
console.log(result); // Output: Hello, World!

Conditional Rendering

This feature allows you to include conditional logic within your templates. The template string can contain conditional statements that control whether certain parts of the template are rendered.

const doT = require('dot');
const template = doT.template('{{? it.show }}Hello, {{=it.name}}!{{?}}');
const result = template({ show: true, name: 'World' });
console.log(result); // Output: Hello, World!

Looping

This feature allows you to loop over arrays within your templates. The template string can contain loop statements that iterate over arrays and render each item.

const doT = require('dot');
const template = doT.template('{{~it.items :item:index}}<li>{{=item}}</li>{{~}}');
const result = template({ items: ['Item 1', 'Item 2', 'Item 3'] });
console.log(result); // Output: <li>Item 1</li><li>Item 2</li><li>Item 3</li>

Other packages similar to dot

Keywords

FAQs

Package last updated on 07 Dec 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc